import axios from 'axios';
import qs from 'qs';
import router from './router.js';



axios.defaults.baseURL = "http://94.191.75.107:3000";
axios.defaults.withCredentials = true;
axios.defaults.transformRequest = [
    function (data) {
        return qs.stringify(data);
    }
]

export default {
    install(Vue) {
        Vue.prototype.axios = axios;
        Vue.prototype.isLogin = async function (flag = 0, path = '/login') {
            const {
                data: {
                    data
                }
            } = await axios({
                url: '/users/islogin'
            });
            if (data == flag) {
                this.$router.push({
                    path
                });
            }
        }
    }
}